package com.ytjj.qmyx.admin.service.impl;

import com.ytjj.qmyx.admin.mapper.DeptMapper;
import com.ytjj.qmyx.admin.model.Admin;
import com.ytjj.qmyx.admin.model.Dept;
import com.ytjj.qmyx.admin.service.AdminService;
import com.ytjj.qmyx.admin.service.CommonService;
import com.ytjj.qmyx.admin.utils.UserUtil;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;

/**
 * 公共方法
 */

@Service
public class CommonServiceImpl implements CommonService {

    @Resource
    private AdminService adminService;
    @Resource
    private DeptMapper deptMapper;

    /**
     * 判断该查询人是否招商部同事
     * @return
     */
    @Override
    public String getAdminName() {
        String userId= UserUtil.getPrincipal();
        Admin admin = adminService.getAdminByEmail(userId);
        Dept dept = deptMapper.selectDept(admin.getDeptId());
        //测试
        if (dept.getDeptName().contains("招商") && ("采购,采购助理,商务助理,招商主管").contains(admin.getRoleName())){
            return admin.getCompellation();
        }
        return null;
    }
}
